package com.example.team.controller;

import com.example.team.entity.Vehicle;
import com.example.team.service.IVehicleService;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * 编写者：蓝江富
 * 2023年10月29日21:11:37
 */
@RestController
@Api(tags = "车辆管理")
public class VehicleController {
    @Autowired
    private IVehicleService vehicleService;

    @ApiOperation(value = "添加车辆",
            notes = "车牌号license不能为空")
    @RequestMapping("/insertVehicle")
    public int insertVehicle(Vehicle vehicle){
        return vehicleService.insertVehicle(vehicle);
    }

    @ApiOperation(value = "删除车辆",
            notes = "成功返回1")
    @RequestMapping("/deleteVehicle")
    public int deleteVehicle(Integer id){
        Vehicle vehicle=new Vehicle();
        vehicle.setVehicleId(id);
        return vehicleService.deleteVehicle(vehicle);
    }

    @ApiOperation(value = "修改用户信息",
            notes = "成功返回1")
    @RequestMapping("/updateVehicle")
    public int updateVehicle(Vehicle vehicle){
        return vehicleService.updateVehicle(vehicle);
    }

    @ApiOperation(value = "查询所有车辆信息",
            notes = "成功返回Json")
    @RequestMapping("/getAllVehicle")
    public List<Vehicle> getAllVehicle(String license){
        Vehicle vehicle=new Vehicle();
        vehicle.setLicense(license);
        return vehicleService.getAllVehicle(vehicle);
    }

    @ApiOperation(value = "查询车辆信息",
            notes = "成功返回Json")
    @RequestMapping("/getVehicle")
    public Vehicle getVehicle(String license){
        Vehicle vehicle=new Vehicle();
        vehicle.setLicense(license);
        return vehicleService.getVehicle(vehicle);
    }
    @ApiOperation(value = "距离保修时间")
    @RequestMapping("/vehicleW")
    public String vehicleW(String license){
        Vehicle vehicle=new Vehicle();
        vehicle.setLicense(license);
        return vehicleService.reminder(vehicle);
    }
}
